{extend name="main" /}

{block name="body"}
{include file="breadcrumb" /}
<div class="layui-fluid">
    <div class="layui-card">
        <div class=" layui-card-header layuiadmin-card-header-auto">
            <form class="layui-form" method="get">
                <input type="hidden" name="bcid" value="{:input('bcid')}"><!--保留当前位置的bcid参数-->
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">订单号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ordernum" placeholder="请输入关键字" value="{:input('ordernum')}" autocomplete="off" class="layui-input" >
                        </div>
                    </div>
                   <!-- <div class="layui-inline">
                        <label class="layui-form-label">开始日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="start_date" id="start_date" value="{:input('start_date')}"
                                   placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">截止日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_date" id="end_date" value="{:input('end_date')}"
                                   placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                        </div>
                    </div> -->
                    <div class="layui-inline">
                        <button class="layui-btn">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-card-body">
            <div class="btn-box">
                <!-- <a href="{:url('add')}" class="layui-btn layui-btn-sm xn_open" data-width="90%" data-height="94%">添加订单管理</a> -->
                <button type="button" lay-on="deleteAll" class="layui-btn layui-btn-danger layui-btn-sm" title="">
                    删除选中
                </button>
            </div>
			<div style="overflow-x: auto;">
            <table class="layui-table" style="width:2000px;">
                <thead>
                <tr>
                    <th width="25">
                        <div class="layui-form">
                            <input type="checkbox" name="selectAll" lay-filter="selectAll">
                        </div>
                    </th>
                    <!-- <th width="25">ID</th> -->
					 
                    <th>订单号</th>
					<th>快递单</th>
					<th width="80">用户</th>
					<th width="450">地址</th>
					<th width="80">备注</th>
                    <th width="80">数量</th>
                    <th width="80">租期</th>
                    <th width="80">押金</th>
                    <th width="80">价格</th>
					<th width="80">支付</th>
					<th width="100">签收</th>
					<th width="80">发货</th>
                    <th width="300">时间</th>
					<th width="300">签收时间</th>
					<th width="300">开始-结束</th>
                    <th width="300">操作</th>
                </tr>
                </thead>
                <tbody>
                {foreach name="list" item="vo"}
                <tr>
                    <td>
                        <div class="layui-form">
                            <input class="item-id" type="checkbox" name="id[]" value="{$vo.id}">
                        </div>
                    </td>
                    <!-- <td>{$vo.id}</td> -->
                    <td>{$vo.ordernum}</td>
					<td>{if $vo.deliverorder}{$vo.deliverorder}{else}暂无{/if}</td>
					<td>{$vo.nickName}</td>
					<td>{$vo.address}</td>
					<td>{$vo.remark}</td>
                    <td>{$vo.num}</td>
                    <td>{$vo.lease}</td>
                    <td>{$vo.rent}</td>
                    <td>{$vo.price}</td>
					<td>{if $vo.paystatus==0}待支付{else}已支付{/if}</td>
					<td>{if $vo.state==0}暂无轨迹{elseif $vo.state==1}已揽收{elseif $vo.state==2}在途中{else}已签收{/if}</td>
					<td>{if $vo.deliver_status==0}未发货{else}已发货{/if}</td>
                    <td>{$vo.create_time}</td>
					<td>{$vo.sign_time|date="Y-m-d H:i:s"}</td>
					<td>{$vo.start_time|date="Y-m-d H:i:s"}至{$vo.end_time|date="Y-m-d H:i:s"}</td>
                    <td>
                        <a href="{:url('edit',array('id'=>$vo['id']))}" class="layui-btn layui-btn-sm xn_open"
                           data-width="90%" data-height="94%">
                            修改
                        </a>
                        <a href="{:url('delete',array('id'=>$vo['id']))}"
                           class="layui-btn layui-btn-danger layui-btn-sm xn_delete">
                            删除
                        </a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
			</div>
            <div class="layui-row">
                <div class="pages">{$list|raw}</div>
                {include file="list_rows" /}
            </div>
        </div>
    </div>

</div>
{/block}

{block name="js"}
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start_date'
        });
        laydate.render({
            elem: '#end_date'
        });
    });

    //全选
    layui.use(function () {
        var form = layui.form;
        var layer = layui.layer;
        var util = layui.util;

        //全选
        form.on('checkbox(selectAll)', function (data) {
            var child = $(".item-id");
            child.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

        //选中删除
        util.on('lay-on', {
            deleteAll: function () {
                var child = $(".item-id");
                var ids = [];
                child.each(function (index, item) {
                    if (item.checked === true) {
                        ids.push(item.value)
                    }
                });
                if (ids.length === 0) {
                    layer.msg('未选中数据', {icon: 2});
                    return false;
                }
                layer.confirm('确定要删除所选吗？', {
                    btn: ['确定', '关闭'] //按钮
                }, function () {
                    var url = "{:url('delete')}";
                    $.post(url, {id: ids}, function (res) {
                        if (res.code === 1) {
                            layer.msg('删除成功', {icon: 1, time: 1000}, function () {
                                window.location.reload();
                            });
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'json')
                });
            }
        });
    });
</script>
{/block}